<!doctype html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>购物车</title>
    <link rel="stylesheet" href="/static/lyCart/css/reset(1).css" th:href="@{/lyCart/css/reset(1).css}">
    <link rel="stylesheet" href="/static/lyCart/css/carts.css" th:href="@{/lyCart/css/carts.css}">
    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
</head>
<body>
<section class="cartMain">
    <div class="cartMain_hd">
        <ul class="order_lists cartTop" >
            <li class="list_chk">
                <!--所有商品全选-->
                <input type="checkbox" id="all" class="whole_check">
                <label for="all"></label>
                全选
            </li>
            <li class="list_con">商品信息</li>
            <li class="list_info">商品参数</li>
            <li class="list_price">单价</li>
            <li class="list_amount">数量</li>
            <li class="list_sum">金额</li>
            <li class="list_op">操作</li>
        </ul>
    </div>
    <div th:each="y:${list2}">
        <div class="cartBox" >
            <div class="shop_info">
                <div class="all_check">
                    <!--店铺全选-->
                    <input type="checkbox" th:id="${y.id}" class="shopChoice">
                    <label th:for="${y.id}+1" class="shop"></label>
                </div>
                <div class="shop_name">
                    店铺：<a href="javascript:;" th:text="${y.name}"></a>
                </div>
            </div>
            <div class="order_content">
                <tr th:each="x:${list}" >

                    <ul class="order_lists" th:if="${y.name}==${x.products.seller}">
                        <li class="list_chk">
                            <input type="checkbox" th:id="${x.id}+1" name="ddd" class="son_check" th:value="${x.productId}">
                            <label th:for="${x.id}+1"></label>
                        </li>
                        <li class="list_con">
                            <div class="list_img"><a href="javascript:;"><img  th:src="@{/lyCart/images/1.png}" alt=""></a></div>
                            <div class="list_text"><a href="javascript:;" th:text="${x.products.subTitle}"></a></div>
                        </li>
                        <li class="list_info">
                            <p>规格：默认</p>
                            <p>尺寸：16*16*3(cm)</p>
                        </li>
                        <li class="list_price">
                            <p class="price" th:text="'￥'+${x.products.promotePrice}"></p>
                        </li>
                        <li class="list_amount">
                            <div class="amount_box">
                                <a href="javascript:;" class="reduce reSty">-</a>
                                <input type="text" value="1" class="sum">
                                <a href="javascript:;" class="plus">+</a>
                            </div>
                        </li>
                        <li class="list_sum">
                            <p class="sum_price" th:text="'￥'+${x.products.promotePrice}"></p>
                        </li>
                        <li class="list_op">
                            <p class="del"><a href="javascript:;" class="delBtn">移除商品</a></p>
                        </li>
                        <!--                <p hidden="hidden" th:text="${x.products.id}"></p>-->
                    </ul>
                </tr>
            </div>
        </div>
    </div>


    <!--底部-->
    <div class="bar-wrapper">
        <div class="bar-right">
            <div class="piece">已选商品<strong class="piece_num">0</strong>件</div>
            <div class="totalMoney">共计: <strong class="total_text" id="total">0.00</strong></div>
            <div class="calBtn"><a href="javascript:;" onclick="total2()">结算</a></div>
        </div>
    </div>
</section>
<section class="model_bg"></section>
<section class="my_model">
    <p class="title">删除宝贝<span class="closeModel">X</span></p>
    <p>您确认要删除该宝贝吗？</p>
    <div class="opBtn"><a href="javascript:;" class="dialog-sure">确定</a><a href="javascript:;" class="dialog-close">关闭</a></div>
</section>
<script src="/static/lyCart/js/jquery-1.11.0.min.js" th:src="@{/lyCart/js/jquery-1.11.0.min.js}"></script>
<script src="/static/lyCart/js/carts.js" th:src="@{/lyCart/js/carts.js}"></script>
<script>
    function total2() {
        var  $sonCheckBox = $('.son_check');
        var   $shopCheckbox = $('.shopChoice');
        var   $cartBox = $('.cartBox');
        var oneTotal = '';//单独一个产品的数量和总价
        var oneNumber = '';
        var total_money = 0;//总共的数量，价钱
        var total_count = 0;
        var calBtn = $('.calBtn a');
        $sonCheckBox.each(function () {
            if ($(this).is(':checked')) {
                var goods = parseInt($(this).parents('.order_lists').find('.sum_price').html().substring(1));
                var num =  parseInt($(this).parents('.order_lists').find('.sum').val());
                oneTotal+=goods+',';
                oneNumber+=num+',';
                total_money += goods;
                total_count += num;
            }
        });

        // alert(total_money);
        // alert( total_count);
        // console.log("总的"+total_money)
        // console.log("总的"+total_count)
        // console.log("单的"+oneTotal)
        // console.log("单的"+oneNumber)
        var obj = document.getElementsByName("ddd");
        var check_val = [];
        for( var k in obj){
            if(obj[k].checked)
                check_val.push(obj[k].value);
        }
        alert(check_val.constructor);//得到

        $.ajax({
            url:"/tmall/oderItem",
            type:"post",
            dataType:"json",
            traditional: true,
            data:{"oneTotal":oneTotal,"oneNumber":oneNumber,"total_money":total_money,"total_count":total_count,"check_val":check_val},
            success:function (result) {


            },
            error:function (err) {
                layer.msg('ajax请求失败!',{icon: 5,time:1000});
            },

        });
    }
</script>
</body>
</html>